Skip to content

fix(watchdog): alert when a wrong build holds the opencode port (#8255) - #8295

Merged
dezren39 merged 1 commit into
mainfrom
fix/8255-watchdog-build-check
Nov 10, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/8255-watchdog-build-check

Conversation

@dezren39

@dezren39 dezren39 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

What

The opencode watchdog (code#7780) treats any serving port as healthy. On 2026-11-10 that blind spot hid the #8255 failure for ~2 days: port 13420 served a two-generations-old build while generation switches reported success, because a service-mode starter silently defers to any registered incumbent.

This PR adds a build-identity assertion to the watchdog:

  • When opencode.service is active, the watchdog reads the registered service's version from /api/info (credentials from the channel registration file, never printed) and compares it against the new services.opencode-watchdog.expectedVersion option.
  • home/common sets expectedVersion from the name of the very cascade package derivation the unit runs — expectation and ExecStart resolve from one derivation and cannot drift apart (evaluates to 2.0.30+3497ea2 on current main, matching production).
  • A mismatch held past the grace window alerts on the same surface as the dark case (the watchdog unit exits 1 until a healthy run) but never restarts a serving unit: replacement is the switch procedure's deliberate act, and the watchdog must never race a lifecycle handover.
  • Only a positively different reported version counts; an unreadable registration/probe is not evidence. Registration file is channel-selected (services.opencode-watchdog.channel, default prod). Test hooks: OPENCODE_WATCHDOG_EXPECTED_VERSION / OPENCODE_WATCHDOG_REGISTRATION_FILE.

Verification

Refs #8255


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…#8255)

The dark-port watchdog (code#7780) treats any serving port as
healthy, so on 2026-11-10 it stayed silent while a
two-generations-old build held port 13420 for ~2 days and
generation switches reported success.

Add a build-identity assertion: when opencode.service is active,
the watchdog reads the registered service version from /api/info
(credentials from the channel registration file) and compares it
with services.opencode-watchdog.expectedVersion, which home/common
derives from the name of the same cascade package the unit runs —
expectation and ExecStart resolve from one derivation. A mismatch
held past the grace window alerts on the same surface as the dark
case (the watchdog unit exits 1) but never restarts a serving
unit: replacing a wrong build is the switch procedure's
deliberate act, and the watchdog must never race a handover. An
unreadable registration or probe is not evidence; only a
positively different version counts. Test hooks:
OPENCODE_WATCHDOG_EXPECTED_VERSION /
OPENCODE_WATCHDOG_REGISTRATION_FILE.
@dezren39
dezren39 requested a review from a team as a code owner November 10, 2026 21:28
@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 98503bec-6a71-4e41-af30-f3ee09a9b5c0
Commits

Reviewing files that changed from the base of the PR and between 95766e8 and 27d19d3.

Files selected for processing: 2

  • home/common/default.nix
  • nixos/services/opencode-watchdog/default.nix
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T21:30:34.623333Z 27d19d3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27d19d35a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread home/common/default.nix
};


services.opencode-watchdog.expectedVersion = watchdogExpectedVersion;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Set the expected version in the NixOS module scope

home/common is merged into home-manager.users.user, .root, and .backup by home/{user,root,backup}/default.nix, but services.opencode-watchdog.expectedVersion is declared in the NixOS module at nixos/services/opencode-watchdog/default.nix:156–174, not in Home Manager. This assignment therefore defines an unknown Home Manager option and prevents configurations importing this shared file from evaluating. It also does not populate the NixOS watchdog's cfg.expectedVersion, whose empty default disables the new identity check. Move the assignment to the NixOS configuration scope while retaining the same package-derived version.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant